﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;

namespace SzCourt.WebSite.manager
{
    public partial class cpwsEx_detail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AdminSession.SessionBox.CheckUserSession())
            {
                Response.Redirect("/manager/login.aspx");
            }
            if (!this.IsPostBack)
            {
                getInfo();
            }
        }

        private void getInfo()
        {
            int _id = string.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"]);

            string SessionUserName = AdminSession.SessionBox.GetUserSession().UserName;

            RefereeDoc bll = new RefereeDoc();
            pRefereeDocComment result = (pRefereeDocComment)bll.GetCommentInfo(_id);

            if (result != null)
            {
                this.tdAddDateTime.InnerHtml = result.AddDateTime.ToString();
                this.tdAddIP.InnerHtml = result.AddIP.ToString();
                this.tdAddUserName.InnerHtml = result.AddUserName;
                this.tdContent.InnerHtml = result.Conent;
                this.acpview.HRef = "/shenwu/cpview.aspx?id="+result.RefereeDocID.ToString();
                this.hdnID.Value = result.CommentID.ToString();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string UserName= AdminSession.SessionBox.GetUserSession().UserName;
            if (UserName.ToLower().StartsWith("plsh") || UserName.ToLower().StartsWith("sysadmin") || UserName.ToLower().StartsWith("liang"))
            {
                int _id = string.IsNullOrEmpty(this.hdnID.Value) ? 0 : Convert.ToInt32(this.hdnID.Value);
                RefereeDoc bll = new RefereeDoc();
                bool result = (bool)bll.AuditComment(_id);

                if (result)
                {
                    this.spanMessage.InnerHtml = "审核成功！";
                }
                else
                {
                    this.spanMessage.InnerHtml = "审核失败！";
                }
            }
            else
            {
                this.spanMessage.InnerHtml = "审核失败！没有评论审核权限！";
            }
        }

    }
}